﻿
@{
    Layout = "~/Areas/Manage/Views/Shared/_Layout.cshtml";
    ViewBag.Title = "登录";
}
<link href="/Content/css/H-ui.login.css" rel="stylesheet" type="text/css" />
<link href="/Content/lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet" type="text/css" />
<div class="loginWraper">
    <div id="loginform" class="loginBox">
        <div style="text-align:center;"><b>InShare 网站管理系统V1.0</b></div>
        <form class="form form-horizontal" id="formLogin">
            <div class="row cl">
                <label class="form-label col-3"><i class="Hui-iconfont">&#xe60d;</i></label>
                <div class="formControls col-8">
                    <input id="" name="userName" type="text" placeholder="用户名" class="input-text size-L">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-3"><i class="Hui-iconfont">&#xe60e;</i></label>
                <div class="formControls col-8">
                    <input id="" name="passWord" type="password" placeholder="密码" class="input-text size-L">
                </div>
            </div>
            <div class="row cl">
                <div class="formControls col-8 col-offset-3">
                    <input class="input-text size-L" type="text" name="VerifyCode" placeholder="验证码" style="width:150px;">
                    <img src="~/Main/CreateVerifyCode" id="imgVerifyCode"><a id="kanbuq" href="javascript:;">看不清，换一张</a>
                </div>
            </div>
            @*<div class="row">
                <div class="formControls col-8 col-offset-3">
                    <label for="online">
                        <input type="checkbox" name="online" id="online" value="">
                        使我保持登录状态
                    </label>
                </div>
            </div>*@
            <div class="row">
                <div class="formControls col-8 col-offset-3">
                    <input type="hidden" name="IpAddress" id="ipmsg" value=""/>
                    <input id="btnLogin" type="button" class="btn btn-success radius size-L" value="&nbsp;登&nbsp;&nbsp;&nbsp;&nbsp;录&nbsp;">
                    <input name="" type="reset" class="btn btn-default radius size-L" value="&nbsp;取&nbsp;&nbsp;&nbsp;&nbsp;消&nbsp;">
                </div>
            </div>
        </form>
    </div>
</div>
<div class="footer">Copyright InShare 网站管理系统 by LHP</div>
@section FooterScript
{
    <script type="text/javascript" src="http://pv.sohu.com/cityjson?ie=utf-8" charset="utf-8"></script>
    <script type="text/javascript">
        var i = returnCitySN;
        var alertMsg = 'IP:' + i['cip'] + '所在地' + i['cname'];
        document.getElementById('ipmsg').value = alertMsg;
    </script>
    <!--<script type="text/javascript" src="~/lib/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="~/js/H-ui.js"></script>-->
    <script type="text/javascript">
        $(function () {
            var checkLogin = $("#checkLogin").val();
            if (checkLogin > 0) {
                layer.msg('当前已有账户登录', { icon: 1, time: 2000 });
            }

            $("#kanbuq,#imgVerifyCode").click(function () {
                $("#imgVerifyCode").attr("src", "/Main/CreateVerifyCode?" + Math.random());
            });

            //为了避免页面刚打开的时候加载缓存中的"Main/CreateVerifyCode"
            //因此要主动点击一下，刷新验证码
            $("#imgVerifyCode").click();

            $("#btnLogin").click(function () {
                var formData = $("#formLogin").serializeArray();
                $.ajax({
                    url: "/Manage/Main/Login", dataType: "json",
                    type: "post", data: formData,
                    success: function (res) {
                        if (res.Status == "OK") {
                            location.href = "/Manage/Main/Index";//如果登录成功，则自动跳转到首页
                        } else {
                            alert("错误消息" + res.ErrorMsg);
                            $("#imgVerifyCode").click();//验证码常见BUG:用户登录错误，需要再刷新一下验证码
                        }
                    }, error: function () {
                        alert("网络出错");
                    }
                });
            });

        });
    </script>
}